package algotithm.acwing.math.test1381;

import java.io.*;

/**
 * @author zhouyanxiang
 * @Date 2021-01-2021/1/25-14:16
 */
public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader reader  = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

        int n = Integer.parseInt(String.valueOf(reader.read()));
        int d2 = 0, d5 = 0, c = 1;
        for (int i = 2; i <= n ; i++) {
            int j = i;
            while (j % 2 == 0) {
                j /= 2;
                d2++;
            }

            while (j % 5 == 0) {
                j /= 5;
                d5++;
            }
            c = c*j % 10;
        }
        for (int i = 0; i < d2 - d5; i++) {
            c = c*2 % 10;
        }
        writer.write(c + "\n");
        writer.flush();
        writer.close();
        reader.close();
    }

}
